
 <!DOCTYPE HTML>
<html >
<head>
  <meta charset="UTF-8">
  
    <title>缓存穿透解决方案 | Typhoon&#39;s code space</title>
    <meta name="viewport" content="width=device-width, initial-scale=1,user-scalable=no">
    
    <meta name="author" content="typhoon">
    

    
    <meta name="description" content="在并发很大的情况下,使用缓存能很大程度上缓解服务器和数据库层的压力,然而随着技术的发展,缓存也暴露除了很多问题, 比如说:缓存穿透、缓存雪崩、缓存并发、缓存失效、数据一致性问题,今天就缓存穿透问题做一下分析和给出具体的解决方案">
<meta name="keywords" content="缓存穿透解决方案">
<meta property="og:type" content="article">
<meta property="og:title" content="缓存穿透解决方案">
<meta property="og:url" content="http://scorpioaeolus.oschina.io/2017/08/28/缓存穿透解决方案/index.html">
<meta property="og:site_name" content="Typhoon&#39;s code space">
<meta property="og:description" content="在并发很大的情况下,使用缓存能很大程度上缓解服务器和数据库层的压力,然而随着技术的发展,缓存也暴露除了很多问题, 比如说:缓存穿透、缓存雪崩、缓存并发、缓存失效、数据一致性问题,今天就缓存穿透问题做一下分析和给出具体的解决方案">
<meta property="og:image" content="http://scorpioaeolus.oschina.io/typhoon/2017/08/28/缓存穿透解决方案/1.png">
<meta property="og:image" content="http://scorpioaeolus.oschina.io/typhoon/2017/08/28/缓存穿透解决方案/2.png">
<meta property="og:image" content="http://scorpioaeolus.oschina.io/typhoon/2017/08/28/缓存穿透解决方案/3.png">
<meta property="og:image" content="http://scorpioaeolus.oschina.io/typhoon/2017/08/28/缓存穿透解决方案/4.png">
<meta property="og:image" content="http://scorpioaeolus.oschina.io/typhoon/2017/08/28/缓存穿透解决方案/5.png">
<meta property="og:image" content="http://scorpioaeolus.oschina.io/typhoon/2017/08/28/缓存穿透解决方案/6.png">
<meta property="og:image" content="http://scorpioaeolus.oschina.io/typhoon/2017/08/28/缓存穿透解决方案/7.png">
<meta property="og:image" content="http://scorpioaeolus.oschina.io/typhoon/2017/08/28/缓存穿透解决方案/8.png">
<meta property="og:image" content="http://scorpioaeolus.oschina.io/typhoon/2017/08/28/缓存穿透解决方案/9.png">
<meta property="og:image" content="http://scorpioaeolus.oschina.io/typhoon/2017/08/28/缓存穿透解决方案/10.png">
<meta property="og:image" content="http://scorpioaeolus.oschina.io/typhoon/2017/08/28/缓存穿透解决方案/11.png">
<meta property="og:image" content="http://scorpioaeolus.oschina.io/typhoon/2017/08/28/缓存穿透解决方案/12.png">
<meta property="og:updated_time" content="2017-08-28T03:03:29.036Z">
<meta name="twitter:card" content="summary">
<meta name="twitter:title" content="缓存穿透解决方案">
<meta name="twitter:description" content="在并发很大的情况下,使用缓存能很大程度上缓解服务器和数据库层的压力,然而随着技术的发展,缓存也暴露除了很多问题, 比如说:缓存穿透、缓存雪崩、缓存并发、缓存失效、数据一致性问题,今天就缓存穿透问题做一下分析和给出具体的解决方案">
<meta name="twitter:image" content="http://scorpioaeolus.oschina.io/typhoon/2017/08/28/缓存穿透解决方案/1.png">

    
    <link rel="alternative" href="/atom.xml" title="Typhoon&#39;s code space" type="application/atom+xml">
    
    
    <link rel="icon" href="/typhoon/img/java.png">
    
    
    <link rel="apple-touch-icon" href="/typhoon/img/jacman.jpg">
    <link rel="apple-touch-icon-precomposed" href="/typhoon/img/jacman.jpg">
    
    <link rel="stylesheet" href="/typhoon/css/style.css">
</head>

  <body>
    <header>
      
<div>
		
			<div id="imglogo">
				<a href="/typhoon/"><img src="/typhoon/img/java.png" alt="Typhoon&#39;s code space" title="Typhoon&#39;s code space"/></a>
			</div>
			
			<div id="textlogo">
				<h1 class="site-name"><a href="/typhoon/" title="Typhoon&#39;s code space">Typhoon&#39;s code space</a></h1>
				<h2 class="blog-motto"></h2>
			</div>
			<div class="navbar"><a class="navbutton navmobile" href="#" title="Menu">
			</a></div>
			<nav class="animated">
				<ul>
					<ul>
					 
						<li><a href="/typhoon/">主页</a></li>
					
						<li><a href="/typhoon/archives">归档</a></li>
					
						<li><a href="/typhoon/about">关于</a></li>
					
					<li>
 					
					<form class="search" action="//google.com/search" method="get" accept-charset="utf-8">
						<label>Search</label>
						<input type="search" id="search" name="q" autocomplete="off" maxlength="20" placeholder="Search" />
						<input type="hidden" name="q" value="site:scorpioaeolus.oschina.io">
					</form>
					
					</li>
				</ul>
			</nav>			
</div>
    </header>
    <div id="container">
      <div id="main" class="post" itemscope itemprop="blogPost">
  
	<article itemprop="articleBody"> 
		<header class="article-info clearfix">
  <h1 itemprop="name">
    
      <a href="/typhoon/2017/08/28/缓存穿透解决方案/" title="缓存穿透解决方案" itemprop="url">缓存穿透解决方案</a>
  </h1>
  <p class="article-author">By
       
		<a href="/typhoon/about" title="typhoon" target="_blank" itemprop="author">typhoon</a>
		
  <p class="article-time">
    <time datetime="2017-08-28T02:41:16.000Z" itemprop="datePublished"> Published 2017-08-28</time>
    
  </p>
</header>
	<div class="article-content">
		
		<div id="toc" class="toc-article">
			<strong class="toc-title">Contents</strong>
		
			<ol class="toc"><li class="toc-item toc-level-5"><a class="toc-link" href="#为什么用缓存"><span class="toc-number">1.</span> <span class="toc-text">为什么用缓存?</span></a></li><li class="toc-item toc-level-5"><a class="toc-link" href="#概念"><span class="toc-number">2.</span> <span class="toc-text">概念</span></a></li><li class="toc-item toc-level-5"><a class="toc-link" href="#分析"><span class="toc-number">3.</span> <span class="toc-text">分析</span></a></li><li class="toc-item toc-level-5"><a class="toc-link" href="#解决方案"><span class="toc-number">4.</span> <span class="toc-text">解决方案</span></a></li><li class="toc-item toc-level-5"><a class="toc-link" href="#缓存null实现方案"><span class="toc-number">5.</span> <span class="toc-text">缓存null实现方案</span></a></li><li class="toc-item toc-level-5"><a class="toc-link" href="#代码分析与解读"><span class="toc-number">6.</span> <span class="toc-text">代码分析与解读</span></a></li><li class="toc-item toc-level-5"><a class="toc-link" href="#单元测试验证结果"><span class="toc-number">7.</span> <span class="toc-text">单元测试验证结果</span></a></li><li class="toc-item toc-level-5"><a class="toc-link" href="#总结"><span class="toc-number">8.</span> <span class="toc-text">总结</span></a></li></ol>
		
		</div>
		
		<pre><code>在并发很大的情况下,使用缓存能很大程度上缓解服务器和数据库层的压力,然而随着技术的发展,缓存也暴露除了很多问题,
比如说:缓存穿透、缓存雪崩、缓存并发、缓存失效、数据一致性问题,今天就缓存穿透问题做一下分析和给出具体的解决方案
</code></pre><a id="more"></a>
<h5 id="为什么用缓存"><a href="#为什么用缓存" class="headerlink" title="为什么用缓存?"></a>为什么用缓存?</h5><pre><code>我们可以这样理解,所有的缓存都是内存数据库,而我们常用的oracle和mysql等关系型数据库都是硬盘数据库,两者最大的区别就是,
内存数据库io速度远大于关系数据库的磁盘io,所以查询性能比较好,应用中使用缓存后查询流程大致如下:
</code></pre><img src="/typhoon/2017/08/28/缓存穿透解决方案/1.png" alt="result" title="result">
<h5 id="概念"><a href="#概念" class="headerlink" title="概念"></a>概念</h5><pre><code>缓存穿透,从字面上意思讲,就是请求不走缓存直接访问数据库,当然这只是最表层的意思.更深一层的意思是请求进到服务中,
去各种缓存组件(redis,memcached等)中查询是否存在,如果存在就返回,如果不存在就去数据库中查询并将结果放入缓存。
而缓存穿透就是很多可以断定不存在查询结果的请求或者非法恶意攻击请求,频繁查询数据库,给数据库造成压力甚至拖垮数据库.
</code></pre><h5 id="分析"><a href="#分析" class="headerlink" title="分析"></a>分析</h5><pre><code>之所以存在缓存穿透,是因为我们在使用缓存的场景下,大多数只缓存有效结果,也就是只缓存数据库真是存在的数据,
而对于查询结果为null的数据是没有缓存的,这样每一次返回null的请求都会到数据库中查询,并且查询结果是null(频繁查询数据库返回无效数据),
在并发很大的情况下,无效的查询占用数据库连接,影响正常业务请求性能,给数据库造成很大的压力。一种极端的情况下,
可以对这些接口做恶意非法请求,导致大部分连接不可用,拖垮数据库
</code></pre><h5 id="解决方案"><a href="#解决方案" class="headerlink" title="解决方案"></a>解决方案</h5><pre><code> 针对缓存穿透,有很多解决方案,最常用的就是一下两种:
 1)缓存为null的查询结果,将null或者其他具有标志性的符号(##,$$)存储到数据库 
 2)使用布隆过滤器(感兴趣可以自己去了解,不做赘述)


此处我们将分析第一种解决方案方案和实现案例
</code></pre><h5 id="缓存null实现方案"><a href="#缓存null实现方案" class="headerlink" title="缓存null实现方案"></a>缓存null实现方案</h5><pre><code>I)业务层代码实现
</code></pre><figure class="highlight plain"><table><tr><td class="gutter"><pre><div class="line">1</div><div class="line">2</div><div class="line">3</div><div class="line">4</div><div class="line">5</div><div class="line">6</div><div class="line">7</div><div class="line">8</div><div class="line">9</div><div class="line">10</div><div class="line">11</div><div class="line">12</div><div class="line">13</div><div class="line">14</div><div class="line">15</div><div class="line">16</div><div class="line">17</div><div class="line">18</div><div class="line">19</div><div class="line">20</div><div class="line">21</div><div class="line">22</div><div class="line">23</div><div class="line">24</div><div class="line">25</div><div class="line">26</div><div class="line">27</div><div class="line">28</div><div class="line">29</div><div class="line">30</div><div class="line">31</div><div class="line">32</div><div class="line">33</div><div class="line">34</div><div class="line">35</div><div class="line">36</div><div class="line">37</div><div class="line">38</div><div class="line">39</div><div class="line">40</div><div class="line">41</div><div class="line">42</div></pre></td><td class="code"><pre><div class="line">/**</div><div class="line">*根据id查询客诉单</div><div class="line">* @author Typhoon</div><div class="line">* @date 2017-08-21 15:37 Monday</div><div class="line">* @since V1.3.1</div><div class="line">*/</div><div class="line">@Override</div><div class="line">public ComplaintInfoDto queryById(Long id) &#123;</div><div class="line">String key = &quot;complaintInfo_cache:pk&quot; + id;</div><div class="line">ComplaintInfoDto dto = null;</div><div class="line">try &#123;</div><div class="line">//*①去缓存查询*</div><div class="line">Object obj = RedisUtils.get(key, Object.class);</div><div class="line">if(null != obj) &#123;//②查询结果不为空有两种情况,1)存储的空标识,2)真实数据</div><div class="line">if(&quot;##&quot;.equals(obj.toString())) &#123;//如果返回结果为##(为空的特殊标识),避免缓存穿透,直接返回给调用方null</div><div class="line">return null;</div><div class="line">&#125;</div><div class="line">dto = (ComplaintInfoDto) obj;//真实数据</div><div class="line">&#125;</div><div class="line">&#125; catch (Exception e) &#123;</div><div class="line">LOGGER.error(&quot;&quot;,e);</div><div class="line">&#125;</div><div class="line">if(null != dto) &#123;//缓存中存在有效的数据</div><div class="line">return dto;</div><div class="line">&#125;</div><div class="line">ComplaintInfo info = this.complaintInfoDao.queryByPrimaryKey(id);</div><div class="line">if (null == info) &#123;</div><div class="line">try &#123;</div><div class="line">RedisUtils.setObject(key, &quot;##&quot;, 300);</div><div class="line">&#125; catch (Exception e) &#123;</div><div class="line">LOGGER.error(&quot;&quot;,e);</div><div class="line">&#125;</div><div class="line">return null;</div><div class="line">&#125;</div><div class="line">dto =BeanUtils.toBean(info, ComplaintInfoDto.class);</div><div class="line">try &#123;</div><div class="line">RedisUtils.setObject(key, dto, 300);</div><div class="line">&#125; catch (Exception e) &#123;</div><div class="line">LOGGER.error(&quot;&quot;,e);</div><div class="line">&#125;</div><div class="line">return dto;</div><div class="line">&#125;</div></pre></td></tr></table></figure>
<h5 id="代码分析与解读"><a href="#代码分析与解读" class="headerlink" title="代码分析与解读"></a>代码分析与解读</h5><p><em>1.查询缓存数据并分析:</em></p>
<img src="/typhoon/2017/08/28/缓存穿透解决方案/2.png" alt="result" title="result">
<ul>
<li>第一个标红处,从缓存中查询数据,并赋值给Object类型(如果是标识null值的特殊字符,无法转换为具体的数据类型)</li>
<li><p>第二个标红处,if(null != obj)有两种情况,一种是缓存中存在真实有效数据,另一种就是存储的是标识null值的特殊字符,如下代码需要优先判断是否是特殊标识,如果是直接返回null值给调用方,如果不是特殊字符才转换为有效数据(否则如果不做判断就做转换会报类型转换异常)</p>
<figure class="highlight plain"><table><tr><td class="gutter"><pre><div class="line">1</div><div class="line">2</div><div class="line">3</div></pre></td><td class="code"><pre><div class="line">if(&quot;##&quot;.equals(obj.toString())) &#123;//如果返回结果为##(为空的特殊标识),避免缓存穿透,直接返回给调用方null</div><div class="line">return null;</div><div class="line">&#125;</div></pre></td></tr></table></figure>
</li>
<li><p><strong>注意</strong>:代码块用try…catch包裹,这是一个值得注意的点,因为我们查询缓存的工具可能是别人封装的服务或者工具类,还有具体的redis服务器是否可访问等问题,都有可能造成抛出异常,如果不捕获异常的话,程序运行到这里就终止了,也就意味着缓存的暂时不可用导致我们的正常业务流程中断,这对于使用者或者严谨的开发人员是无法接受的。毕竟缓存只是一种提高访问性能的外部构件,不可用我就不用缓存呗,牺牲一点性能来提升程序的流畅性和完整性,这样做是完全可行的。所以此处包括后续缓存操作代码块我都做了捕获异常</p>
</li>
</ul>
<p><em>2.如果缓存存在有效数据就返回,没有就直接到DB中查询:</em></p>
<img src="/typhoon/2017/08/28/缓存穿透解决方案/3.png" alt="result" title="result">
<ul>
<li>第一个标红处如果缓存中存在有效数据,直接返回调用</li>
<li>第二个标红处是到DB中查询数据</li>
<li>接着判断DB查询结果是否为null,如果为null的话,将标识null的特殊字符放入缓存(设置过期时间5分钟,避免insert有效数据后导致查询长时间为null),记得try…catch缓存操作,保证缓存不可用的情况下DB查询正常使用</li>
</ul>
<p><em>3.对DB中查询出的有效数据进行装配转换并返回结果</em></p>
<img src="/typhoon/2017/08/28/缓存穿透解决方案/4.png" alt="result" title="result">
<ul>
<li>第一个标红处对DB查询结果进行装配转换成调用方需要的数据(<strong><em>客户端需要什么数据就返回什么数据,尽可能不要原封不懂得将查询的所有字段都返回给调用方,否则我们的表结构就一览无余的暴露给调用方了,在调用方非自己项目组或者非本公司的时候是非常不安全的</em></strong>)</li>
<li>第二个标红处将有效数据放入缓存(捕获异常)</li>
<li>最后返回有效数据</li>
</ul>
<h5 id="单元测试验证结果"><a href="#单元测试验证结果" class="headerlink" title="单元测试验证结果"></a>单元测试验证结果</h5><figure class="highlight plain"><table><tr><td class="gutter"><pre><div class="line">1</div><div class="line">2</div><div class="line">3</div><div class="line">4</div><div class="line">5</div><div class="line">6</div><div class="line">7</div><div class="line">8</div><div class="line">9</div><div class="line">10</div></pre></td><td class="code"><pre><div class="line">@Test</div><div class="line">public void testQueryById() &#123;</div><div class="line">Long id = -1L;</div><div class="line">try &#123;</div><div class="line">ComplaintInfoDto dto = this.complaintInfoService.queryById(id);</div><div class="line">LOGGER.info(&quot;请求响应:&#123;&#125;&quot;,JSON.toJSONString(dto));</div><div class="line">&#125; catch (Exception e) &#123;</div><div class="line">LOGGER.info(&quot;&quot;,e);</div><div class="line">&#125;</div><div class="line">&#125;</div></pre></td></tr></table></figure>
<p><em>1. 无效查询条件测试</em></p>
<img src="/typhoon/2017/08/28/缓存穿透解决方案/5.png" alt="result" title="result">
<img src="/typhoon/2017/08/28/缓存穿透解决方案/6.png" alt="result" title="result">
<pre><code>第一次访问,缓存中没有有效数据也没有null数据标识
</code></pre><img src="/typhoon/2017/08/28/缓存穿透解决方案/7.png" alt="result" title="result">
<pre><code>数据库中没有查到数据,将null数据标识放入缓存并返回null
</code></pre><img src="/typhoon/2017/08/28/缓存穿透解决方案/8.png" alt="result" title="result">
<pre><code>第二次无效访问,缓存中返回null值标识##,逻辑中识别无效请求直接返回null,不再去DB中查询
</code></pre><p><em>2. 有效查询条件测试</em></p>
<img src="/typhoon/2017/08/28/缓存穿透解决方案/9.png" alt="result" title="result">
<img src="/typhoon/2017/08/28/缓存穿透解决方案/10.png" alt="result" title="result">
<pre><code>缓存中没有查到数据,去DB中查询
</code></pre><img src="/typhoon/2017/08/28/缓存穿透解决方案/11.png" alt="result" title="result">
<pre><code>DB中查到数据,做转换后放入缓存
</code></pre><img src="/typhoon/2017/08/28/缓存穿透解决方案/12.png" alt="result" title="result">
<pre><code>第二次有效查询,从缓存中查询出有效数据直接返回
</code></pre><h5 id="总结"><a href="#总结" class="headerlink" title="总结"></a>总结</h5><pre><code>至此,我们已经使用缓存存储null值的方式解决了缓存穿透的问题,每一个事情都有好的一面和坏的一面,当然这种方式也存在弊端,下面总结一下这种方式的优缺点:
</code></pre><ul>
<li>优点:实现方式简单;可控性强</li>
<li>缺点:缓存中存储了null值或者是代表null值的特殊字符</li>
</ul>
<p><em>PS</em>:原创不易,请多多支持!</p>
  
	</div>
		<footer class="article-footer clearfix">
<div class="article-catetags">

<div class="article-categories">
  <span></span>
  <a class="article-category-link" href="/typhoon/categories/缓存/">缓存</a>
</div>


  <div class="article-tags">
  
  <span></span> <a href="/typhoon/tags/缓存穿透解决方案/">缓存穿透解决方案</a>
  </div>

</div>



	<div class="article-share" id="share">
	
	  <div data-url="http://scorpioaeolus.oschina.io/2017/08/28/缓存穿透解决方案/" data-title="缓存穿透解决方案 | Typhoon&#39;s code space" data-tsina="null" class="share clearfix">
	  </div>
	
	</div>


</footer>

   	       
	</article>
	
<nav class="article-nav clearfix">
 
 <div class="prev" >
 <a href="/typhoon/2017/08/28/使用本地缓存/" title="使用本地缓存">
  <strong>上一篇：</strong><br/>
  <span>
  使用本地缓存</span>
</a>
</div>


<div class="next">
<a href="/typhoon/2017/08/22/免配置使用spring中JdbcTemplate/"  title="免配置使用spring中JdbcTemplate">
 <strong>下一篇：</strong><br/> 
 <span>免配置使用spring中JdbcTemplate
</span>
</a>
</div>

</nav>

	


</div>  
      <div class="openaside"><a class="navbutton" href="#" title="Show Sidebar"></a></div>

  <div id="toc" class="toc-aside">
  <strong class="toc-title">Contents</strong>
 
 <ol class="toc"><li class="toc-item toc-level-5"><a class="toc-link" href="#为什么用缓存"><span class="toc-number">1.</span> <span class="toc-text">为什么用缓存?</span></a></li><li class="toc-item toc-level-5"><a class="toc-link" href="#概念"><span class="toc-number">2.</span> <span class="toc-text">概念</span></a></li><li class="toc-item toc-level-5"><a class="toc-link" href="#分析"><span class="toc-number">3.</span> <span class="toc-text">分析</span></a></li><li class="toc-item toc-level-5"><a class="toc-link" href="#解决方案"><span class="toc-number">4.</span> <span class="toc-text">解决方案</span></a></li><li class="toc-item toc-level-5"><a class="toc-link" href="#缓存null实现方案"><span class="toc-number">5.</span> <span class="toc-text">缓存null实现方案</span></a></li><li class="toc-item toc-level-5"><a class="toc-link" href="#代码分析与解读"><span class="toc-number">6.</span> <span class="toc-text">代码分析与解读</span></a></li><li class="toc-item toc-level-5"><a class="toc-link" href="#单元测试验证结果"><span class="toc-number">7.</span> <span class="toc-text">单元测试验证结果</span></a></li><li class="toc-item toc-level-5"><a class="toc-link" href="#总结"><span class="toc-number">8.</span> <span class="toc-text">总结</span></a></li></ol>
 
  </div>

<div id="asidepart">
<div class="closeaside"><a class="closebutton" href="#" title="Hide Sidebar"></a></div>
<aside class="clearfix">

  


  
<div class="categorieslist">
	<p class="asidetitle">Categories</p>
		<ul>
		
		  
			<li><a href="/typhoon/categories/dubbo/" title="dubbo">dubbo<sup>8</sup></a></li>
		  
		
		  
			<li><a href="/typhoon/categories/java性能优化/" title="java性能优化">java性能优化<sup>17</sup></a></li>
		  
		
		  
			<li><a href="/typhoon/categories/java源码分析/" title="java源码分析">java源码分析<sup>1</sup></a></li>
		  
		
		  
			<li><a href="/typhoon/categories/motan/" title="motan">motan<sup>2</sup></a></li>
		  
		
		  
			<li><a href="/typhoon/categories/spring/" title="spring">spring<sup>11</sup></a></li>
		  
		
		  
			<li><a href="/typhoon/categories/springboot/" title="springboot">springboot<sup>28</sup></a></li>
		  
		
		  
			<li><a href="/typhoon/categories/springmvc/" title="springmvc">springmvc<sup>1</sup></a></li>
		  
		
		  
			<li><a href="/typhoon/categories/容器/" title="容器">容器<sup>1</sup></a></li>
		  
		
		  
			<li><a href="/typhoon/categories/工具/" title="工具">工具<sup>7</sup></a></li>
		  
		
		  
			<li><a href="/typhoon/categories/性能优化/" title="性能优化">性能优化<sup>5</sup></a></li>
		  
		
		  
			<li><a href="/typhoon/categories/架构/" title="架构">架构<sup>8</sup></a></li>
		  
		
		  
			<li><a href="/typhoon/categories/案例分析/" title="案例分析">案例分析<sup>13</sup></a></li>
		  
		
		  
			<li><a href="/typhoon/categories/缓存/" title="缓存">缓存<sup>4</sup></a></li>
		  
		
		  
			<li><a href="/typhoon/categories/设计模式/" title="设计模式">设计模式<sup>3</sup></a></li>
		  
		
		  
			<li><a href="/typhoon/categories/面试题/" title="面试题">面试题<sup>1</sup></a></li>
		  
		
		</ul>
</div>


  
<div class="tagslist">
	<p class="asidetitle">Tags</p>
		<ul class="clearfix">
		
			
				<li><a href="/typhoon/tags/springboot/" title="springboot">springboot<sup>28</sup></a></li>
			
		
			
				<li><a href="/typhoon/tags/java性能优化/" title="java性能优化">java性能优化<sup>9</sup></a></li>
			
		
			
				<li><a href="/typhoon/tags/限流/" title="限流">限流<sup>3</sup></a></li>
			
		
			
				<li><a href="/typhoon/tags/Spring5/" title="Spring5">Spring5<sup>3</sup></a></li>
			
		
			
				<li><a href="/typhoon/tags/设计模式/" title="设计模式">设计模式<sup>3</sup></a></li>
			
		
			
				<li><a href="/typhoon/tags/案例分析/" title="案例分析">案例分析<sup>2</sup></a></li>
			
		
			
				<li><a href="/typhoon/tags/性能优化/" title="性能优化">性能优化<sup>2</sup></a></li>
			
		
			
				<li><a href="/typhoon/tags/Spring/" title="Spring">Spring<sup>2</sup></a></li>
			
		
			
				<li><a href="/typhoon/tags/dubbo/" title="dubbo">dubbo<sup>2</sup></a></li>
			
		
			
				<li><a href="/typhoon/tags/分页/" title="分页">分页<sup>2</sup></a></li>
			
		
			
				<li><a href="/typhoon/tags/并发/" title="并发">并发<sup>2</sup></a></li>
			
		
			
				<li><a href="/typhoon/tags/异常拦截/" title="异常拦截">异常拦截<sup>1</sup></a></li>
			
		
			
				<li><a href="/typhoon/tags/dubbo分布式事务/" title="dubbo分布式事务">dubbo分布式事务<sup>1</sup></a></li>
			
		
			
				<li><a href="/typhoon/tags/自带图片/" title="自带图片">自带图片<sup>1</sup></a></li>
			
		
			
				<li><a href="/typhoon/tags/svn导出mvn项目/" title="svn导出mvn项目">svn导出mvn项目<sup>1</sup></a></li>
			
		
			
				<li><a href="/typhoon/tags/dubbo过滤器/" title="dubbo过滤器">dubbo过滤器<sup>1</sup></a></li>
			
		
			
				<li><a href="/typhoon/tags/排序性能对比/" title="排序性能对比">排序性能对比<sup>1</sup></a></li>
			
		
			
				<li><a href="/typhoon/tags/ListenableFuture/" title="ListenableFuture">ListenableFuture<sup>1</sup></a></li>
			
		
			
				<li><a href="/typhoon/tags/PropertyChangeListener/" title="PropertyChangeListener">PropertyChangeListener<sup>1</sup></a></li>
			
		
			
				<li><a href="/typhoon/tags/jdbcTemplate高可用/" title="jdbcTemplate高可用">jdbcTemplate高可用<sup>1</sup></a></li>
			
		
		</ul>
</div>


  <div class="linkslist">
  <p class="asidetitle">Links</p>
    <ul>
        
          <li>
            
            	<a href="https://coderq.com" target="_blank" title="一个面向程序员交流分享的新一代社区">码农圈</a>
            
          </li>
        
          <li>
            
            	<a href="http://wuchong.me" target="_blank" title="Jark&#39;s Blog">Jark&#39;s Blog</a>
            
          </li>
        
    </ul>
</div>

  


  <div class="rsspart">
	<a href="/atom.xml" target="_blank" title="rss">RSS</a>
</div>

  <div class="weiboshow">
  <p class="asidetitle">Weibo</p>
    <iframe width="100%" height="119" class="share_self"  frameborder="0" scrolling="no" src="http://widget.weibo.com/weiboshow/index.php?language=&width=0&height=119&fansRow=2&ptype=1&speed=0&skin=9&isTitle=1&noborder=1&isWeibo=0&isFans=0&uid=null&verifier=b3593ceb&dpc=1"></iframe>
</div>


</aside>
</div>
    </div>
    <footer><div id="footer" >
	
	<div class="line">
		<span></span>
		<div class="author"></div>
	</div>
	
	
	<section class="info">
		<p> Hello ,I&#39;m a java coder. <br/>
			This is my blog,believe it or not.</p>
	</section>
	 
	<div class="social-font" class="clearfix">
		
		
		
		
		
		
		
		
		
		
		<a href="mailto:ScorpioAeolus@163.com" target="_blank" class="icon-email" title="Email Me"></a>
		
	</div>
			
		

		<p class="copyright">
		Powered by <a href="http://hexo.io" target="_blank" title="hexo">hexo</a> and Theme by <a href="https://github.com/wuchong/jacman" target="_blank" title="Jacman">Jacman</a> © 2019 
		
		<a href="/typhoon/about" target="_blank" title="typhoon">typhoon</a>
		
		
		</p>
</div>
</footer>
    <script src="/typhoon/js/jquery-2.0.3.min.js"></script>
<script src="/typhoon/js/jquery.imagesloaded.min.js"></script>
<script src="/typhoon/js/gallery.js"></script>
<script src="/typhoon/js/jquery.qrcode-0.12.0.min.js"></script>

<script type="text/javascript">
$(document).ready(function(){ 
  $('.navbar').click(function(){
    $('header nav').toggleClass('shownav');
  });
  var myWidth = 0;
  function getSize(){
    if( typeof( window.innerWidth ) == 'number' ) {
      myWidth = window.innerWidth;
    } else if( document.documentElement && document.documentElement.clientWidth) {
      myWidth = document.documentElement.clientWidth;
    };
  };
  var m = $('#main'),
      a = $('#asidepart'),
      c = $('.closeaside'),
      o = $('.openaside');
  c.click(function(){
    a.addClass('fadeOut').css('display', 'none');
    o.css('display', 'block').addClass('fadeIn');
    m.addClass('moveMain');
  });
  o.click(function(){
    o.css('display', 'none').removeClass('beforeFadeIn');
    a.css('display', 'block').removeClass('fadeOut').addClass('fadeIn');      
    m.removeClass('moveMain');
  });
  $(window).scroll(function(){
    o.css("top",Math.max(80,260-$(this).scrollTop()));
  });
  
  $(window).resize(function(){
    getSize(); 
    if (myWidth >= 1024) {
      $('header nav').removeClass('shownav');
    }else{
      m.removeClass('moveMain');
      a.css('display', 'block').removeClass('fadeOut');
      o.css('display', 'none');
      
      $('#toc.toc-aside').css('display', 'none');
        
    }
  });
});
</script>

<script type="text/javascript">
$(document).ready(function(){ 
  var ai = $('.article-content>iframe'),
      ae = $('.article-content>embed'),
      t  = $('#toc'),
      ta = $('#toc.toc-aside'),
      o  = $('.openaside'),
      c  = $('.closeaside');
  if(ai.length>0){
    ai.wrap('<div class="video-container" />');
  };
  if(ae.length>0){
   ae.wrap('<div class="video-container" />');
  };
  c.click(function(){
    ta.css('display', 'block').addClass('fadeIn');
  });
  o.click(function(){
    ta.css('display', 'none');
  });
  $(window).scroll(function(){
    ta.css("top",Math.max(140,320-$(this).scrollTop()));
  });
});
</script>


<script type="text/javascript">
$(document).ready(function(){ 
  var $this = $('.share'),
      url = $this.attr('data-url'),
      encodedUrl = encodeURIComponent(url),
      title = $this.attr('data-title'),
      tsina = $this.attr('data-tsina'),
      description = $this.attr('description');
  var html = [
  '<div class="hoverqrcode clearfix"></div>',
  '<a class="overlay" id="qrcode"></a>',
  '<a href="https://www.facebook.com/sharer.php?u=' + encodedUrl + '" class="article-share-facebook" target="_blank" title="Facebook"></a>',
  '<a href="https://twitter.com/intent/tweet?url=' + encodedUrl + '" class="article-share-twitter" target="_blank" title="Twitter"></a>',
  '<a href="#qrcode" class="article-share-qrcode" title="微信"></a>',
  '<a href="http://widget.renren.com/dialog/share?resourceUrl=' + encodedUrl + '&srcUrl=' + encodedUrl + '&title=' + title +'" class="article-share-renren" target="_blank" title="人人"></a>',
  '<a href="http://service.weibo.com/share/share.php?title='+title+'&url='+encodedUrl +'&ralateUid='+ tsina +'&searchPic=true&style=number' +'" class="article-share-weibo" target="_blank" title="微博"></a>',
  '<span title="Share to"></span>'
  ].join('');
  $this.append(html);

  $('.hoverqrcode').hide();

  var myWidth = 0;
  function updatehoverqrcode(){
    if( typeof( window.innerWidth ) == 'number' ) {
      myWidth = window.innerWidth;
    } else if( document.documentElement && document.documentElement.clientWidth) {
      myWidth = document.documentElement.clientWidth;
    };
    var qrsize = myWidth > 1024 ? 200:100;
    var options = {render: 'image', size: qrsize, fill: '#2ca6cb', text: url, radius: 0.5, quiet: 1};
    var p = $('.article-share-qrcode').position();
    $('.hoverqrcode').empty().css('width', qrsize).css('height', qrsize)
                          .css('left', p.left-qrsize/2+20).css('top', p.top-qrsize-10)
                          .qrcode(options);
  };
  $(window).resize(function(){
    $('.hoverqrcode').hide();
  });
  $('.article-share-qrcode').click(function(){
    updatehoverqrcode();
    $('.hoverqrcode').toggle();
  });
  $('.article-share-qrcode').hover(function(){}, function(){
      $('.hoverqrcode').hide();
  });
});   
</script>









<link rel="stylesheet" href="/typhoon/fancybox/jquery.fancybox.css" media="screen" type="text/css">
<script src="/typhoon/fancybox/jquery.fancybox.pack.js"></script>
<script type="text/javascript">
$(document).ready(function(){ 
  $('.article-content').each(function(i){
    $(this).find('img').each(function(){
      if ($(this).parent().hasClass('fancybox')) return;
      var alt = this.alt;
      if (alt) $(this).after('<span class="caption">' + alt + '</span>');
      $(this).wrap('<a href="' + this.src + '" title="' + alt + '" class="fancybox"></a>');
    });
    $(this).find('.fancybox').each(function(){
      $(this).attr('rel', 'article' + i);
    });
  });
  if($.fancybox){
    $('.fancybox').fancybox();
  }
}); 
</script>



<!-- Analytics Begin -->



<script>
var _hmt = _hmt || [];
(function() {
  var hm = document.createElement("script");
  hm.src = "//hm.baidu.com/hm.js?e6d1f421bbc9962127a50488f9ed37d1";
  var s = document.getElementsByTagName("script")[0]; 
  s.parentNode.insertBefore(hm, s);
})();
</script>



<!-- Analytics End -->

<!-- Totop Begin -->

	<div id="totop">
	<a title="Back to Top"><img src="/typhoon/img/scrollup.png"/></a>
	</div>
	<script src="/typhoon/js/totop.js"></script>

<!-- Totop End -->

<!-- MathJax Begin -->
<!-- mathjax config similar to math.stackexchange -->


<!-- MathJax End -->

<!-- Tiny_search Begin -->

<!-- Tiny_search End -->

  </body>
</html>
